/*
 Copyright (C) 2009 QDSS.org
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.qdss.persist;

import java.io.Serializable;

import org.qdss.persist.engine.entry.ID;


/**
 * 
 * 
 * @author <a href="mailto:zhaofang123@gmail.com">FANGFANG ZHAO</a>
 * @since 0.1.0, Feb 10, 2009
 * @version $Id: PersistManager.java 65 2010-03-02 05:07:52Z zhaofang123@gmail.com $
 */
public interface PersistManager extends Serializable {

	/**
	 * 获取持久化管理器工场
	 * 
	 * @return
	 */
	PersistManagerFactory getPersistManagerFactory();
	
	/**
	 * 保存记录
	 * 
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	Record save(Record record) throws DataAccessException;
	
	/**
	 * 更新记录
	 * 
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	Record update(Record record) throws DataAccessException;
	
	/**
	 * 保存或更新记录（根据主键值）
	 * 
	 * @param record
	 * @return
	 * @throws DataAccessException
	 */
	Record saveOrUpdate(Record record) throws DataAccessException;
	
	/**
	 * 删除记录（包含级联删除）
	 * 
	 * @param id
	 * @return
	 * @throws DataAccessException
	 */
	int delete(ID id) throws DataAccessException;
	
	/**
	 * 删除多调记录（包含级联删除）
	 * 
	 * @param ids
	 * @return
	 * @throws DataAccessException
	 */
	int[] delete(ID[] ids) throws DataAccessException;
}
